home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / kzr0597.zip / POT.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-10  |  3KB  |  89 lines

  1. /*  REXX-Programm  pot(x,y) für die Funktion  x hoch y */
  2.  
  3.    Call RxFuncAdd 'SysLoadFuncs', RexxUtil, 'SysLoadFuncs'
  4.    Call SysLoadFuncs
  5.    signal on syntax name potMsg
  6.  
  7. /* Diese Variablen müssen für jede Prozedur definiert werden, damit die  */
  8. /* Prozedur die Variable bufND kennt und die Variable ND übernehmen kann.*/
  9.    Pfd=SysSearchPath("PATH", "kzr.cmd")
  10.    lp=LastPos("\", Pfd)
  11.    Pfd=DelStr(Pfd, 1+lp)
  12.    NDApot=Pfd||"NDApot.DAT"
  13.    bufND =Pfd||"NDZahl.DAT"
  14.    bufMsg=Pfd||"Meldung.DAT"
  15.    ND = LineIn(bufND, 1)
  16.  
  17.    if ND > 400 then
  18.    do
  19.      ND=400
  20.      call charout(NDApot) ; Call SysFileDelete NDApot
  21.      ret=LineOut(NDApot, 400)
  22.      Call Charout,"   Achtung, nur 400 Dezimalstellen bei der Berechnung von  pot(.. , ..)"
  23.      say
  24.      Beep(444, 200); Beep(628, 300)  /* Hier kein EXIT ! */
  25.    end
  26.  
  27.   /* Wenn ND <= 400 ist, wird ND = ND  weitergegeben */
  28.    call charout(NDApot) ; Call SysFileDelete NDApot
  29.    ret=LineOut(NDApot, ND)
  30.  
  31.    NUMERIC DIGITS ND+6
  32.  
  33.    arg xx,y,s
  34.  
  35.    if length(s) > 0 then
  36.    do
  37.      call charout(NDApot) ; Call SysFileDelete NDApot
  38.      ret=LineOut(bufMsg, "Im Argument von  pot(.. , ..)  ist mindestens  1  nicht zulässiges Komma !")
  39.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  40.   /*  damit in den diesbezüglichen temporären Dateien                      */
  41.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  42.      EXIT
  43.    end
  44.  
  45.    if xx=0 & y=0 then do u=1; SIGNAL W; end
  46.    if xx=0 & y=1 then do u=0; SIGNAL W; end
  47.    if xx=1 & y=0 then do u=1; SIGNAL W; end
  48.  
  49.    /* Wenn y geradzahlig ist, xx**y verwenden. */
  50.    if abs(y)//1 = 0 then do; u=xx**y; Signal W; end
  51.  
  52.    /* y ist nicht ganzzahlig */
  53.    if xx < 0 & abs(y)//1 <> 0 then
  54.    do
  55.      call charout(NDApot) ; Call SysFileDelete NDApot
  56.      ret=LineOut(bufMsg, "Die Potenz " xx"  hoch  "y"  ist keine reelle Zahl !")
  57.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  58.   /*  damit in den diesbezüglichen temporären Dateien                      */
  59.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  60.      EXIT
  61.    end
  62.  
  63.    /* Wenn xx > 0 ist. */
  64.    vz=+1
  65.    /* Wenn xx < 0 ist. */
  66.    if xx < 0 then
  67.    do
  68.      if abs(y)//2=0 then vz=+1; else vz=-1
  69.    end
  70.  
  71.    x=abs(xx)
  72.    u=vz*exp(y*ln(x))
  73.  
  74. W: NUMERIC DIGITS ND
  75.    return(Format(u))
  76.  
  77. potMsg:
  78.    sf=ErrorText(RC)
  79.    if  Pos("Bad arithmetic conversion", sf) > 0 then
  80.    do
  81.      call charout(NDApot) ; Call SysFileDelete NDApot
  82.      ret=LineOut(bufMsg, "Sie haben in  pot(.. , ..)  keine gültigen Argumente eingegeben !")
  83.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  84.   /*  damit in den diesbezüglichen temporären Dateien                      */
  85.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  86.      EXIT
  87.    end
  88.  
  89.